<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改数据库')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-field-edit" th:object="${sysDbTableField}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">字段名称(英文)：</label>
                <div class="col-sm-8">
                    <input name="fieldName" th:field="*{fieldName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">字段类型：</label>
                <div class="col-sm-8">
                    <select name="fieldType" class="form-control m-b" th:with="type=${@dict.getType('sys_db_field_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{fieldType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否主键：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_true_false')}">
                        <input type="radio" th:id="${dict.dictCode}" name="fieldIsPrimaryKey" th:value="${dict.dictValue}" th:field="*{fieldIsPrimaryKey}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">长度：</label>
                <div class="col-sm-8">
                    <input name="fieldLength" th:field="*{fieldLength}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">小数点：</label>
                <div class="col-sm-8">
                    <input name="fieldDecimal" th:field="*{fieldDecimal}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group" id="sys_true_false">
                <label class="col-sm-3 control-label">是否为空：</label>
                <div class="col-sm-8">
                    <div  class="radio-box" th:each="dict : ${@dict.getType('sys_true_false')}">
                        <input id="fieldIsNull" type="radio" th:id="${dict.dictCode}" name="fieldIsNull" th:value="${dict.dictValue}" th:field="*{fieldIsNull}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">默认值：</label>
                <div class="col-sm-8">
                    <input name="fieldDefaultValue" th:field="*{fieldDefaultValue}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">注释：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" th:field="*{remark}"  type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/field";
        $("#form-field-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-field-edit').serialize());
            }
        }
        $(function() {
            $("input[name='fieldIsPrimaryKey']").on('ifChecked', function(event){
                var fieldIsPrimaryKey = $(event.target).val();
                if (fieldIsPrimaryKey==='true') {
                    $("#sys_true_false").hide();
                }else {
                    $("#sys_true_false").show();
                }
            });
        });
    </script>


</body>
</html>